{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from sklearn.metrics import jaccard_score\n",
    "\n",
    "evaluation_folder = '/home/ganlu/bkism_ws/src/BKISemanticMapping/data/semantickitti_04/evaluations/'\n",
    "\n",
    "gt_all = np.array([])\n",
    "pred_all = np.array([])\n",
    "for i in range(271):\n",
    "    print(i)\n",
    "    \n",
    "    result = np.loadtxt(evaluation_folder + str(i).zfill(6) + '.txt', dtype=np.uint32)\n",
    "    gt = result[:,0]\n",
    "    gt = gt & 0xFFFF\n",
    "    pred = result[:,1]\n",
    "    gt_all = np.concatenate((gt_all, gt))\n",
    "    pred_all = np.concatenate((pred_all, pred))\n",
    "    \n",
    "# Ignore background and sky label\n",
    "pred_all = pred_all[gt_all != 0]\n",
    "gt_all = gt_all[gt_all != 0]\n",
    "    \n",
    "print(np.unique(np.concatenate((gt_all, pred_all), axis=0)) )\n",
    "print(jaccard_score(gt_all, pred_all, average=None))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
